package com.sos.service;

import java.util.Iterator;
import java.util.List;

import android.content.Context;
import android.telephony.SmsManager;
import android.widget.Toast;

/**
 * 发送求救短信
 * **/
public class SMSService {
	private Context context;
	private final static String TAG = SMSService.class.getSimpleName();
	public SMSService(Context context)
	{
		this.context = context;
	}
	public int send(String phonenum,String content)
	{
		int ret=0;
		if((phonenum==null||"".equals(phonenum))||(content==null||"".equals(content)))
		{  

			Toast.makeText(context, "电话号码，短信内容不能为空!", Toast.LENGTH_LONG);
			ret=1;
		} 
		else 
		{
			SmsManager manage=SmsManager.getDefault();  
			List<String> all=manage.divideMessage(content);  
			Iterator<String> it=all.iterator();  
			while(it.hasNext())
			{  
				 manage.sendTextMessage(phonenum, null, it.next(), null, null);  //逐条发送短息  
				
	            		
			}
			Toast.makeText(context, "发送成功!", Toast.LENGTH_LONG);
		}
		return ret;
		
	}
}
